/*
 * @Date: 2023-01-22 02:17:37
 * @LastEditors: 恶名扬 2080156129@qq.com
 * @LastEditTime: 2023-01-23 22:08:14
 * @FilePath: \campus-repair-platform\server\schema\manage\admin.js
 */
/**
 * list_schema  获取管理员列表
 * query_schema 查询管理员
 * add_schema   添加管理员
 * update_schema  修改管理员信息
 */

const joi = require("joi")
const {
  phone,
  job_number,
  password,
  name,
  gender,
  state,
  page,
  pagesize,
  id,
} = require("../common")

const permission = joi.number().min(0).max(1).error(new Error("权限格式有误"))

exports.list_schema = {
  query: {
    page,
    pagesize,
    permission,
    state,
  },
}

exports.query_schema = {
  query: {
    job_number: job_number,
  },
}

exports.add_schema = {
  body: {
    job_number: job_number.required(),
    name: name.required(),
    gender: gender.required(),
    permission: permission.required(),
    password: password.required(),
  },
}

exports.update_schema = {
  body: {
    id: id.required(),
    job_number: job_number.required(),
    name: name.required(),
    gender: gender.required(),
    permission: permission.required(),
    phone: phone.optional()
  },
}

exports.lock_schema = {
  body: {
    id: id.required(),
    idLock: joi.boolean().required().error(new Error("是否锁定有误")),
  },
}